/**
* @fileoverview 记录当前打卡状态
* @author Luoob
*/

const STATUS_KEY = 'sign_status'

export const STATUS_WORK = 1
export const STATUS_REST = 0
export type Status = typeof STATUS_WORK | typeof STATUS_REST

/**
 * 获取状态
 */
export function getStatus() {
  return parseInt(localStorage.getItem(STATUS_KEY) || String(STATUS_REST)) as Status
}

/**
 * 更新状态
 */
export function updateStatus(sign: Status) {
  localStorage.setItem(STATUS_KEY, String(sign))
}

/**
 * 重置状态数据
 */
export function resetStatus() {
  updateStatus(STATUS_REST)
}
